<?php if (!defined('THINK_PATH')) exit(); /*a:4:{s:72:"C:\wwwroot\vipwaimai.com\web/../application/admin\view\active\index.html";i:1512803827;s:73:"C:\wwwroot\vipwaimai.com\web/../application/admin\view\public\header.html";i:1503189484;s:71:"C:\wwwroot\vipwaimai.com\web/../application/admin\view\public\city.html";i:1510310973;s:73:"C:\wwwroot\vipwaimai.com\web/../application/admin\view\public\footer.html";i:1512624954;}*/ ?>
﻿<!DOCTYPE html>
<html lang="zh-cn">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="renderer" content="webkit">
		<title><?php echo config('sitename'); ?>-<?php echo lang('label')['Login_title']; ?></title>
		<link rel="stylesheet" type="text/css" href="__ROOT__/static/public/css/pintuer.css" />
		<link rel="stylesheet" type="text/css" href="__ROOT__/static/admin/css/admin.css" />
		<script type="text/javascript" src="__ROOT__/static/public/js/jquery.js"></script>
		<script type="text/javascript" src="__ROOT__/static/public/js/pintuer.js"></script>
		<script type="text/javascript" src="__ROOT__/static/admin/js/admin.js"></script>
		<script type="text/javascript" src="__ROOT__/static/public/layer/layer.js"></script>
		<script type="text/javascript" src="__ROOT__/static/public/laydate/laydate.js"></script>
		<script type="text/javascript" src="__ROOT__/static/public/laytpl/laytpl.js"></script>
	</head>

	<body>
	<style>
		html { overflow-x:hidden; }
	</style>
<link rel="stylesheet" type="text/css" href="__ROOT__/static/public/umeditor/themes/default/css/umeditor.css" />
<script type="text/javascript" src="__ROOT__/static/public/umeditor/third-party/template.min.js"></script>
<script type="text/javascript" src="__ROOT__/static/public/umeditor/umeditor.config.js"></script>
<script type="text/javascript" src="__ROOT__/static/public/umeditor/umeditor.min.js"></script>
<script>
    //city canshu
    var pid = '<?php echo input("get.pid"); ?>';
    var cid = '<?php echo input("get.cid"); ?>';
    var aid = '<?php echo input("get.aid"); ?>';
    var selectc = true;
    var selecta = true;
    function select_a() {
        location.href = '?pid=' + pid + '&cid=' + cid + '&aid=' + aid;
    }
</script>
<?php if(input('get.aid')): if(input('get.title') == '' || input('get.title') == '邀请送好礼'): ?>
<form method="post" class="form-x">
    <div class="panel admin-panel">
        <div class="panel-head"><strong><?php echo lang('currency')['edit']; ?></strong></div>
        <br/>
        <div class="form-group">
            <div class="label">
                <label><?php echo lang('currency')['city']; ?></label>
            </div>
            <div class="field">
                <?php if(input('session.type') == 'province' || input('session.type') == 'all'): ?>
<select id="province" onchange="pchange(this.value)" name="pid" class="input input-auto" >
	<option value="">请选择</option>
</select>
<?php endif; if(input('session.type') == 'province' ||  input('session.type') == 'city' || input('session.type') == 'all'): ?>
<select id="city" onchange="cchange(this.value)" name="cid" class="input input-auto hidden" >
	<option value="">请选择</option>
</select>
<?php endif; ?>
<select id="area" onchange="achange(this.value)" name="aid" class="input input-auto hidden" >
	<option value="">请选择</option>
</select>
<script id="province_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
	<option {{# if(d.data[i].id==pid){ }}selected{{#}}} value="{{ d.data[i].id }}">{{ d.data[i].name }}</option>
	{{# } }}
</script>
<script id="city_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
	<option {{# if(d.data[i].id==cid){ }}selected{{#}}} value="{{ d.data[i].id }}">{{ d.data[i].name }}</option>
	{{# } }}
</script>
<script id="area_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
	<option {{# if(d.data[i].id==aid){ }}selected{{#}}} value="{{ d.data[i].id }}">{{ d.data[i].name }}</option>
	{{# } }}
</script>
<script>
    var func = false;
    $('select').click(function(){
        func = true;
    });
    if(selectc) {
        $('[name=cid]').removeClass('hidden');
    }
    if(selecta){
        $('[name=aid]').removeClass('hidden');
    }
    if('<?php echo input("session.type"); ?>' == 'province' || '<?php echo input("session.type"); ?>' == 'all') {
        $.getJSON('__ROOT__/admin/city/ajax_get?type=province', {}, function (res) {
            var tpl = $("#province_list_tpl").html();
            laytpl(tpl).render(res, function (render) {
                $("#province").html('<option value="">请选择</option>' + render);
            });
            if (pid != '' && pid != 0) {
                $('[name=pid]').change();
            }
        });
    }else if('<?php echo input("session.type"); ?>' == 'city'){
        val = '<?php echo input("session.aid"); ?>';
        if(selectc){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=city&id='+val, {}, function(res){
                var tpl = $("#city_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#city").html('<option value="">请选择</option>' + render);
                    $("#city").val(cid);
                    $("#city").change();
                });
            });
        }
    }else if('<?php echo input("session.type"); ?>' == 'area'){
        val = '<?php echo input("session.aid"); ?>';
        //if(selecta && aid){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=area&nofather=ok&id='+val, {}, function(res){
                var tpl = $("#area_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#area").html('<option value="">请选择</option>'+render);
                });
            });
       // }
    }
    function pchange(val) {
        pid = val;
        if(selectc){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=city&id='+pid, {}, function(res){
                var tpl = $("#city_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#city").html('<option value="">请选择</option>'+render);
                });
                if(selectc == true){
                    if(cid != '' && cid != 0){
                        $('[name=cid]').change();
                    }
                }
            });
        }
        if(func){
            select_p();
        }
    }
    function cchange(val) {
        cid = val;
        if(selecta && cid){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=area&id='+cid, {}, function(res){
                var tpl = $("#area_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#area").html('<option value="">请选择</option>'+render);
                });
            });
        }
        if(func){
            select_c();
        }
    }
    function achange(val) {
        aid = val;
        $('[name=aid]').removeClass('hidden');
        if(func){
            select_a();
        }
    }
</script>
            </div>
        </div>
        <div class="form-group">
            <div class="label">
                <label>活动名称</label>
            </div>
            <div class="field">
                <select name="title" class="input input-auto" onchange="location.href='?pid=<?php echo input("get.pid"); ?>&cid=<?php echo input("get.cid"); ?>&aid=<?php echo input("get.aid"); ?>&title='+this.value;">
                    <option value="">请选择活动</option>
                    <option value="邀请送好礼" <?php if(input('get.title') == '邀请送好礼' || !input('get.title')): ?>selected<?php endif; ?>>邀请送好礼</option>
                    <option value="新用户注册" <?php if(input('get.title') == '新用户注册'): ?>selected<?php endif; ?>>新用户注册</option>
                <option value="分享订单" <?php if(input('get.title') == '分享订单'): ?>selected<?php endif; ?>>分享订单</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <div class="label">
                <label>优惠券</label>
            </div>
            <div class="field">
                <?php if($data['json']): if(is_array($data['json']) || $data['json'] instanceof \think\Collection || $data['json'] instanceof \think\Paginator): $i = 0; $__LIST__ = $data['json'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$json): $mod = ($i % 2 );++$i;?>
                <div>
                    <input type="text" class="input input-auto" name="json[<?php echo $i-1; ?>][full]" size="10" value="<?php echo $json['full']; ?>" placeholder="满足条件"  />
                    <input type="text" class="input input-auto" name="json[<?php echo $i-1; ?>][minus]" size="10" value="<?php echo $json['minus']; ?>" placeholder="减免金额" />
                    <input type="text" class="input input-auto" name="json[<?php echo $i-1; ?>][indate]" size="10" value="<?php echo $json['indate']; ?>" placeholder="有效天数" />
                    <?php if($i == 1): ?>
                    <button type="button" class="button addjson">+</button>
                    <?php else: ?>
                    <button type="button" class="button deljson">-</button>
                    <?php endif; ?>
                </div>
                <?php endforeach; endif; else: echo "" ;endif; else: ?>
                <div>
                    <input type="text" class="input input-auto" name="json[0][full]" size="10" placeholder="满足条件"  />
                    <input type="text" class="input input-auto" name="json[0][minus]" size="10" placeholder="减免金额" />
                    <input type="text" class="input input-auto" name="json[0][indate]" size="10" placeholder="有效天数" />
                    <button type="button" class="button addjson">+</button>
                </div>
                <?php endif; ?>
            </div>
        </div>
       <div class="form-group">
            <div class="label">
                <label><?php echo lang('label')['content']; ?></label>
            </div>
            <div class="field">
                <textarea class="input input-auto" name="description" style="min-width: 580px;min-height: 219px"><?php echo $data['description']; ?></textarea>
            </div>
       </div>
        <div class="form-group">
            <div class="label">
                <label><?php echo lang('label')['status']; ?></label>
            </div>
            <div class="field">
                <div class="button-group button-group-small radio">
                    <label class="button <?php if($data['status'] == 1): ?>active<?php endif; ?>">
                        <input name="status" value="1" <?php if($data['status']== 1): ?>checked="checked" <?php endif; ?> type="radio">
                        <span class="icon icon-check"></span> <?php echo lang('currency')['status_1']; ?>
                    </label>
                    <label class="button <?php if($data['status'] == 0 || !$data['status']): ?>active<?php endif; ?>">
                        <input name="status" value="0" <?php if($data['status']== 0 || !$data['status']): ?>checked="checked" <?php endif; ?>
                        type="radio">
                        <span class="icon icon-times"></span> <?php echo lang('currency')['status_2']; ?>
                    </label>
                </div>
            </div>
        </div>
        <div class="form-button">
            <button class="button bg-main" type="submit"><?php echo lang('form')['submit']; ?></button>
        </div>
        <br/>
        </div>
    </div>
</form>
<script>
    $(".addjson").click(function(){
        var num = $(this).parent().parent().find("div").length;
        var html = '<div><input type="text" class="input input-auto" name="json['+num+'][full]" size="10" placeholder="满足条件"  /> <input type="text" class="input input-auto" name="json['+num+'][minus]" size="10" placeholder="减免金额" /> <input type="text" class="input input-auto" name="json['+num+'][indate]" size="10" placeholder="有效天数"/> <button type="button" class="button deljson">-</button></div>';
        $(this).parent().parent().append(html);
    });
    $(document).on("click",".deljson",function(){
        $(this).parent().remove();
    })
</script>
<?php elseif(input('get.title') == '新用户注册'): ?>
<form method="post" class="form-x">
    <div class="panel admin-panel">
        <div class="panel-head"><strong><?php echo lang('currency')['edit']; ?></strong></div>
        <br/>
        <div class="form-group">
            <div class="label">
                <label><?php echo lang('currency')['city']; ?></label>
            </div>
            <div class="field">
                <?php if(input('session.type') == 'province' || input('session.type') == 'all'): ?>
<select id="province" onchange="pchange(this.value)" name="pid" class="input input-auto" >
	<option value="">请选择</option>
</select>
<?php endif; if(input('session.type') == 'province' ||  input('session.type') == 'city' || input('session.type') == 'all'): ?>
<select id="city" onchange="cchange(this.value)" name="cid" class="input input-auto hidden" >
	<option value="">请选择</option>
</select>
<?php endif; ?>
<select id="area" onchange="achange(this.value)" name="aid" class="input input-auto hidden" >
	<option value="">请选择</option>
</select>
<script id="province_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
	<option {{# if(d.data[i].id==pid){ }}selected{{#}}} value="{{ d.data[i].id }}">{{ d.data[i].name }}</option>
	{{# } }}
</script>
<script id="city_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
	<option {{# if(d.data[i].id==cid){ }}selected{{#}}} value="{{ d.data[i].id }}">{{ d.data[i].name }}</option>
	{{# } }}
</script>
<script id="area_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
	<option {{# if(d.data[i].id==aid){ }}selected{{#}}} value="{{ d.data[i].id }}">{{ d.data[i].name }}</option>
	{{# } }}
</script>
<script>
    var func = false;
    $('select').click(function(){
        func = true;
    });
    if(selectc) {
        $('[name=cid]').removeClass('hidden');
    }
    if(selecta){
        $('[name=aid]').removeClass('hidden');
    }
    if('<?php echo input("session.type"); ?>' == 'province' || '<?php echo input("session.type"); ?>' == 'all') {
        $.getJSON('__ROOT__/admin/city/ajax_get?type=province', {}, function (res) {
            var tpl = $("#province_list_tpl").html();
            laytpl(tpl).render(res, function (render) {
                $("#province").html('<option value="">请选择</option>' + render);
            });
            if (pid != '' && pid != 0) {
                $('[name=pid]').change();
            }
        });
    }else if('<?php echo input("session.type"); ?>' == 'city'){
        val = '<?php echo input("session.aid"); ?>';
        if(selectc){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=city&id='+val, {}, function(res){
                var tpl = $("#city_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#city").html('<option value="">请选择</option>' + render);
                    $("#city").val(cid);
                    $("#city").change();
                });
            });
        }
    }else if('<?php echo input("session.type"); ?>' == 'area'){
        val = '<?php echo input("session.aid"); ?>';
        //if(selecta && aid){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=area&nofather=ok&id='+val, {}, function(res){
                var tpl = $("#area_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#area").html('<option value="">请选择</option>'+render);
                });
            });
       // }
    }
    function pchange(val) {
        pid = val;
        if(selectc){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=city&id='+pid, {}, function(res){
                var tpl = $("#city_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#city").html('<option value="">请选择</option>'+render);
                });
                if(selectc == true){
                    if(cid != '' && cid != 0){
                        $('[name=cid]').change();
                    }
                }
            });
        }
        if(func){
            select_p();
        }
    }
    function cchange(val) {
        cid = val;
        if(selecta && cid){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=area&id='+cid, {}, function(res){
                var tpl = $("#area_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#area").html('<option value="">请选择</option>'+render);
                });
            });
        }
        if(func){
            select_c();
        }
    }
    function achange(val) {
        aid = val;
        $('[name=aid]').removeClass('hidden');
        if(func){
            select_a();
        }
    }
</script>
            </div>
        </div>
        <div class="form-group">
            <div class="label">
                <label>活动名称</label>
            </div>
            <div class="field">
                <select name="title" class="input input-auto" onchange="location.href='?pid=<?php echo input("get.pid"); ?>&cid=<?php echo input("get.cid"); ?>&aid=<?php echo input("get.aid"); ?>&title='+this.value;">
                <option value="">请选择活动</option>
                <option value="邀请送好礼" <?php if(input('get.title') == '邀请送好礼' || !input('get.title')): ?>selected<?php endif; ?>>邀请送好礼</option>
                <option value="新用户注册" <?php if(input('get.title') == '新用户注册'): ?>selected<?php endif; ?>>新用户注册</option>
                <option value="分享订单" <?php if(input('get.title') == '分享订单'): ?>selected<?php endif; ?>>分享订单</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <div class="label">
                <label>优惠券</label>
            </div>
            <div class="field">
                <?php if($data['json']): if(is_array($data['json']) || $data['json'] instanceof \think\Collection || $data['json'] instanceof \think\Paginator): $i = 0; $__LIST__ = $data['json'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$json): $mod = ($i % 2 );++$i;?>
                <div>
                    <input type="text" class="input input-auto" name="json[<?php echo $i-1; ?>][full]" size="10" value="<?php echo $json['full']; ?>" placeholder="满足条件"  required/>
                    <input type="text" class="input input-auto" name="json[<?php echo $i-1; ?>][minus]" size="10" value="<?php echo $json['minus']; ?>" placeholder="减免金额" required/>
                    <input type="text" class="input input-auto" name="json[<?php echo $i-1; ?>][indate]" size="10" value="<?php echo $json['indate']; ?>" placeholder="有效天数" required/>
                    <?php if($i == 1): ?>
                    <button type="button" class="button addjson">+</button>
                    <?php else: ?>
                    <button type="button" class="button deljson">-</button>
                    <?php endif; ?>
                </div>
                <?php endforeach; endif; else: echo "" ;endif; else: ?>
                <div>
                    <input type="text" class="input input-auto" name="json[0][full]" size="10" placeholder="满足条件" required/>
                    <input type="text" class="input input-auto" name="json[0][minus]" size="10" placeholder="减免金额" required/>
                    <input type="text" class="input input-auto" name="json[0][indate]" size="10" placeholder="有效天数" required/>
                    <button type="button" class="button addjson">+</button>
                </div>
                <?php endif; ?>
            </div>
        </div>
        <div class="form-group">
            <div class="input-inline clearfix">
                <div class="label">
                    <label for="image"><?php echo lang('label')['image']; ?></label>
                </div>
                <div class="field">
                    <img width="300" height="120" src="<?php echo $data['image']; ?>" alt="显示图像">
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="input-inline clearfix">
                <div class="label">
                    <label for="image"></label>
                </div>
                <div class="field">
                    <input type="text" readonly class="input input-auto" id="image" name="image" value="<?php echo $data['image']; ?>" size="30" placeholder="<?php echo lang('label')['image']; ?>" required/>
                    <span class="addbtn"><button type="button" data-id="image" class="button upload"><?php echo lang('form')['file']; ?></button></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="label">
                <label><?php echo lang('label')['status']; ?></label>
            </div>
            <div class="field">
                <div class="button-group button-group-small radio">
                    <label class="button <?php if($data['status'] == 1): ?>active<?php endif; ?>">
                        <input name="status" value="1" <?php if($data['status']== 1): ?>checked="checked" <?php endif; ?> type="radio">
                        <span class="icon icon-check"></span> <?php echo lang('currency')['status_1']; ?>
                    </label>
                    <label class="button <?php if($data['status'] == 0 || !$data['status']): ?>active<?php endif; ?>">
                        <input name="status" value="0" <?php if($data['status']== 0 || !$data['status']): ?>checked="checked" <?php endif; ?>
                        type="radio">
                        <span class="icon icon-times"></span> <?php echo lang('currency')['status_2']; ?>
                    </label>
                </div>
            </div>
        </div>
        <div class="form-button">
            <button class="button bg-main" type="submit"><?php echo lang('form')['submit']; ?></button>
        </div>
        <br/>
    </div>
    </div>
</form>
<script>
    $(".addjson").click(function(){
        var num = $(this).parent().parent().find("div").length;
        var html = '<div><input type="text" class="input input-auto" name="json['+num+'][full]" size="10" placeholder="满足条件" required/> <input type="text" class="input input-auto" name="json['+num+'][minus]" size="10" placeholder="减免金额" required/> <input type="text" class="input input-auto" name="json['+num+'][indate]" size="10" placeholder="有效天数" required/> <button type="button" class="button deljson">-</button></div>';
        $(this).parent().parent().append(html);
    });
    $(document).on("click",".deljson",function(){
        $(this).parent().remove();
    })
</script>
<?php elseif(input('get.title') == '分享订单'): ?>
<form method="post" class="form-x">
    <div class="panel admin-panel">
        <div class="panel-head"><strong><?php echo lang('currency')['edit']; ?></strong></div>
        <br/>
        <div class="form-group">
            <div class="label">
                <label><?php echo lang('currency')['city']; ?></label>
            </div>
            <div class="field">
                <?php if(input('session.type') == 'province' || input('session.type') == 'all'): ?>
<select id="province" onchange="pchange(this.value)" name="pid" class="input input-auto" >
	<option value="">请选择</option>
</select>
<?php endif; if(input('session.type') == 'province' ||  input('session.type') == 'city' || input('session.type') == 'all'): ?>
<select id="city" onchange="cchange(this.value)" name="cid" class="input input-auto hidden" >
	<option value="">请选择</option>
</select>
<?php endif; ?>
<select id="area" onchange="achange(this.value)" name="aid" class="input input-auto hidden" >
	<option value="">请选择</option>
</select>
<script id="province_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
	<option {{# if(d.data[i].id==pid){ }}selected{{#}}} value="{{ d.data[i].id }}">{{ d.data[i].name }}</option>
	{{# } }}
</script>
<script id="city_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
	<option {{# if(d.data[i].id==cid){ }}selected{{#}}} value="{{ d.data[i].id }}">{{ d.data[i].name }}</option>
	{{# } }}
</script>
<script id="area_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
	<option {{# if(d.data[i].id==aid){ }}selected{{#}}} value="{{ d.data[i].id }}">{{ d.data[i].name }}</option>
	{{# } }}
</script>
<script>
    var func = false;
    $('select').click(function(){
        func = true;
    });
    if(selectc) {
        $('[name=cid]').removeClass('hidden');
    }
    if(selecta){
        $('[name=aid]').removeClass('hidden');
    }
    if('<?php echo input("session.type"); ?>' == 'province' || '<?php echo input("session.type"); ?>' == 'all') {
        $.getJSON('__ROOT__/admin/city/ajax_get?type=province', {}, function (res) {
            var tpl = $("#province_list_tpl").html();
            laytpl(tpl).render(res, function (render) {
                $("#province").html('<option value="">请选择</option>' + render);
            });
            if (pid != '' && pid != 0) {
                $('[name=pid]').change();
            }
        });
    }else if('<?php echo input("session.type"); ?>' == 'city'){
        val = '<?php echo input("session.aid"); ?>';
        if(selectc){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=city&id='+val, {}, function(res){
                var tpl = $("#city_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#city").html('<option value="">请选择</option>' + render);
                    $("#city").val(cid);
                    $("#city").change();
                });
            });
        }
    }else if('<?php echo input("session.type"); ?>' == 'area'){
        val = '<?php echo input("session.aid"); ?>';
        //if(selecta && aid){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=area&nofather=ok&id='+val, {}, function(res){
                var tpl = $("#area_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#area").html('<option value="">请选择</option>'+render);
                });
            });
       // }
    }
    function pchange(val) {
        pid = val;
        if(selectc){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=city&id='+pid, {}, function(res){
                var tpl = $("#city_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#city").html('<option value="">请选择</option>'+render);
                });
                if(selectc == true){
                    if(cid != '' && cid != 0){
                        $('[name=cid]').change();
                    }
                }
            });
        }
        if(func){
            select_p();
        }
    }
    function cchange(val) {
        cid = val;
        if(selecta && cid){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=area&id='+cid, {}, function(res){
                var tpl = $("#area_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#area").html('<option value="">请选择</option>'+render);
                });
            });
        }
        if(func){
            select_c();
        }
    }
    function achange(val) {
        aid = val;
        $('[name=aid]').removeClass('hidden');
        if(func){
            select_a();
        }
    }
</script>
            </div>
        </div>
        <div class="form-group">
            <div class="label">
                <label>活动名称</label>
            </div>
            <div class="field">
                <select name="title" class="input input-auto" onchange="location.href='?pid=<?php echo input("get.pid"); ?>&cid=<?php echo input("get.cid"); ?>&aid=<?php echo input("get.aid"); ?>&title='+this.value;">
                <option value="">请选择活动</option>
                <option value="邀请送好礼" <?php if(input('get.title') == '邀请送好礼' || !input('get.title')): ?>selected<?php endif; ?>>邀请送好礼</option>
                <option value="新用户注册" <?php if(input('get.title') == '新用户注册'): ?>selected<?php endif; ?>>新用户注册</option>
                <option value="分享订单" <?php if(input('get.title') == '分享订单'): ?>selected<?php endif; ?>>分享订单</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <div class="label">
                <label>优惠券</label>
            </div>
            <div class="field">
                <?php if($data['json']): if(is_array($data['json']) || $data['json'] instanceof \think\Collection || $data['json'] instanceof \think\Paginator): $i = 0; $__LIST__ = $data['json'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$json): $mod = ($i % 2 );++$i;?>
                <div>
                    <input type="text" class="input input-auto" name="json[<?php echo $i-1; ?>][full]" size="10" value="<?php echo $json['full']; ?>" placeholder="满足条件"  required/>
                    <input type="text" class="input input-auto" name="json[<?php echo $i-1; ?>][minus]" size="10" value="<?php echo $json['minus']; ?>" placeholder="减免金额" required/>
                    <input type="text" class="input input-auto" name="json[<?php echo $i-1; ?>][indate]" size="10" value="<?php echo $json['indate']; ?>" placeholder="有效天数" required/>
                    <?php if($i == 1): ?>
                    <button type="button" class="button addjson">+</button>
                    <?php else: ?>
                    <button type="button" class="button deljson">-</button>
                    <?php endif; ?>
                </div>
                <?php endforeach; endif; else: echo "" ;endif; else: ?>
                <div>
                    <input type="text" class="input input-auto" name="json[0][full]" size="10" placeholder="满足条件" required/>
                    <input type="text" class="input input-auto" name="json[0][minus]" size="10" placeholder="减免金额" required/>
                    <input type="text" class="input input-auto" name="json[0][indate]" size="10" placeholder="有效天数" required/>
                    <button type="button" class="button addjson">+</button>
                </div>
                <?php endif; ?>
            </div>
        </div>
        <div class="form-group">
            <div class="label">
                <label><?php echo lang('label')['status']; ?></label>
            </div>
            <div class="field">
                <div class="button-group button-group-small radio">
                    <label class="button <?php if($data['status'] == 1): ?>active<?php endif; ?>">
                        <input name="status" value="1" <?php if($data['status']== 1): ?>checked="checked" <?php endif; ?> type="radio">
                        <span class="icon icon-check"></span> <?php echo lang('currency')['status_1']; ?>
                    </label>
                    <label class="button <?php if($data['status'] == 0 || !$data['status']): ?>active<?php endif; ?>">
                        <input name="status" value="0" <?php if($data['status']== 0 || !$data['status']): ?>checked="checked" <?php endif; ?>
                        type="radio">
                        <span class="icon icon-times"></span> <?php echo lang('currency')['status_2']; ?>
                    </label>
                </div>
            </div>
        </div>
        <div class="form-button">
            <button class="button bg-main" type="submit"><?php echo lang('form')['submit']; ?></button>
        </div>
        <br/>
    </div>
    </div>
</form>
<script>
    $(".addjson").click(function(){
        var num = $(this).parent().parent().find("div").length;
        var html = '<div><input type="text" class="input input-auto" name="json['+num+'][full]" size="10" placeholder="满足条件" required/> <input type="text" class="input input-auto" name="json['+num+'][minus]" size="10" placeholder="减免金额" required/> <input type="text" class="input input-auto" name="json['+num+'][indate]" size="10" placeholder="有效天数" required/> <button type="button" class="button deljson">-</button></div>';
        $(this).parent().parent().append(html);
    });
    $(document).on("click",".deljson",function(){
        $(this).parent().remove();
    })
</script>
<?php endif; else: ?>
<script>
    function select_a() {
        location.href = '?pid=' + pid + '&cid=' + cid + '&aid=' + aid;
    }
</script>
<form method="post" class="form-x">
    <div class="panel admin-panel" style="border: none">
        <br>
        <div class="form-group">
            <div class="label">
                <label><?php echo lang('currency')['city']; ?></label>
            </div>
            <div class="field">
                <?php if(input('session.type') == 'province' || input('session.type') == 'all'): ?>
<select id="province" onchange="pchange(this.value)" name="pid" class="input input-auto" >
	<option value="">请选择</option>
</select>
<?php endif; if(input('session.type') == 'province' ||  input('session.type') == 'city' || input('session.type') == 'all'): ?>
<select id="city" onchange="cchange(this.value)" name="cid" class="input input-auto hidden" >
	<option value="">请选择</option>
</select>
<?php endif; ?>
<select id="area" onchange="achange(this.value)" name="aid" class="input input-auto hidden" >
	<option value="">请选择</option>
</select>
<script id="province_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
	<option {{# if(d.data[i].id==pid){ }}selected{{#}}} value="{{ d.data[i].id }}">{{ d.data[i].name }}</option>
	{{# } }}
</script>
<script id="city_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
	<option {{# if(d.data[i].id==cid){ }}selected{{#}}} value="{{ d.data[i].id }}">{{ d.data[i].name }}</option>
	{{# } }}
</script>
<script id="area_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
	<option {{# if(d.data[i].id==aid){ }}selected{{#}}} value="{{ d.data[i].id }}">{{ d.data[i].name }}</option>
	{{# } }}
</script>
<script>
    var func = false;
    $('select').click(function(){
        func = true;
    });
    if(selectc) {
        $('[name=cid]').removeClass('hidden');
    }
    if(selecta){
        $('[name=aid]').removeClass('hidden');
    }
    if('<?php echo input("session.type"); ?>' == 'province' || '<?php echo input("session.type"); ?>' == 'all') {
        $.getJSON('__ROOT__/admin/city/ajax_get?type=province', {}, function (res) {
            var tpl = $("#province_list_tpl").html();
            laytpl(tpl).render(res, function (render) {
                $("#province").html('<option value="">请选择</option>' + render);
            });
            if (pid != '' && pid != 0) {
                $('[name=pid]').change();
            }
        });
    }else if('<?php echo input("session.type"); ?>' == 'city'){
        val = '<?php echo input("session.aid"); ?>';
        if(selectc){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=city&id='+val, {}, function(res){
                var tpl = $("#city_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#city").html('<option value="">请选择</option>' + render);
                    $("#city").val(cid);
                    $("#city").change();
                });
            });
        }
    }else if('<?php echo input("session.type"); ?>' == 'area'){
        val = '<?php echo input("session.aid"); ?>';
        //if(selecta && aid){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=area&nofather=ok&id='+val, {}, function(res){
                var tpl = $("#area_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#area").html('<option value="">请选择</option>'+render);
                });
            });
       // }
    }
    function pchange(val) {
        pid = val;
        if(selectc){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=city&id='+pid, {}, function(res){
                var tpl = $("#city_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#city").html('<option value="">请选择</option>'+render);
                });
                if(selectc == true){
                    if(cid != '' && cid != 0){
                        $('[name=cid]').change();
                    }
                }
            });
        }
        if(func){
            select_p();
        }
    }
    function cchange(val) {
        cid = val;
        if(selecta && cid){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=area&id='+cid, {}, function(res){
                var tpl = $("#area_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#area").html('<option value="">请选择</option>'+render);
                });
            });
        }
        if(func){
            select_c();
        }
    }
    function achange(val) {
        aid = val;
        $('[name=aid]').removeClass('hidden');
        if(func){
            select_a();
        }
    }
</script>
            </div>
        </div>
        <div class="form-group" style="margin-bottom: 10px">
            <div class="label">
                <label></label>
            </div>
            <div class="field">
                请选择城市后设置
            </div>
        </div>
    </div>
</form>
<?php endif; ?>
<p class="text-center text-gray" style="margin-top:10px;"><a class="text-gray" target="_blank" href="http://www.wm0530.com">完美外卖系统 Power by 网络工厂</a></p>
</body>
<script>
$('.upload').on('click',function (){
		var id = $(this).attr('data-id');
		 upload(id);
	}
);
function upload(id){
	layer.open({
		type:2,
		title:false,
		area: ['70%', '90%'],
		offset: '5%',
		content: "<?php echo url('/admin/material'); ?>?id="+id
	});
}
</script>
</html>